import QtQuick
import QtQuick.Effects
import HuskarUI.Basic

Item {
    id: control

    property alias sourceItem: __source.sourceItem
    property alias sourceRect: __source.sourceRect
    property alias opacityNoise: __noiseImage.opacity
    property alias radiusBlur: __fastBlur.radius
    property color colorTint: '#fff'
    property HusRadius radiusBg: HusRadius { all: 0 }
    property real opacityTint: 0.65
    property real luminosity: 0.01

    objectName: '__HusAcrylic__'

    ShaderEffectSource {
        id: __source
        anchors.fill: parent
        visible: false
        sourceRect: Qt.rect(control.x, control.y, control.width, control.height)
    }

    MultiEffect {
        id: __fastBlur
        anchors.fill: parent
        source: __source
        blurEnabled: true
        blur: 1.0
        blurMax: 32
        property alias radius: __fastBlur.blurMax
    }

    HusRectangleInternal {
        anchors.fill: parent
        color: HusThemeFunctions.alpha('#fff', control.luminosity)
        radius: control.radiusBg.all
        topLeftRadius: control.radiusBg.topLeft
        topRightRadius: control.radiusBg.topRight
        bottomLeftRadius: control.radiusBg.bottomLeft
        bottomRightRadius: control.radiusBg.bottomRight
    }

    HusRectangleInternal {
        anchors.fill: parent
        color: HusThemeFunctions.alpha(control.colorTint, control.opacityTint)
        radius: control.radiusBg.all
        topLeftRadius: control.radiusBg.topLeft
        topRightRadius: control.radiusBg.topRight
        bottomLeftRadius: control.radiusBg.bottomLeft
        bottomRightRadius: control.radiusBg.bottomRight
    }

    Image {
        id: __noiseImage
        anchors.fill: parent
        source: ''
        fillMode: Image.Tile
        opacity: 0.02
    }
}
